% /*******************************************************************************
%  * Round Nearest Even
%  * *****************************************************************************
%  * E.g. 0.10(11) -> 0.1011*2^2 = 10.11 -> 11 -> 11/2^2 -> 0.11
%  * @param x     Input number in [0,1)
%  * @param bits  Significant bits(or #bit to keep)
%  * @return      Rounded number
%  */
function x_round = rnd_rne(x, bits)
scale = 2^bits;
x_dec = x * scale;
if(isequal(x_dec-floor(x_dec),0.5))
    x_rne = round(x_dec/2)*2; 
else
    x_rne = round(x_dec);
end
x_round = double(x_rne/scale);
end